package csc.com.logging;

import java.util.Arrays;
import java.util.Date;

import org.aspectj.lang.JoinPoint;
import org.springframework.beans.factory.annotation.Autowired;

import csc.com.service.WriteFile;


public class Logging {
	
	private WriteFile writeLog;
	
	public WriteFile getWriteLog() {
		return writeLog;
	}
	@Autowired
	public void setWriteLog(WriteFile writeLog) {
		this.writeLog = writeLog;
	}
	public void afterAdvice(JoinPoint joinPoint) {
		String str1 = "Method : " + joinPoint.getSignature().getName() + " is called on "+new Date().toString();
		String str2 = "Arguments : " + Arrays.toString(joinPoint.getArgs());
		writeLog.writeData(str1, str2);
	}
	
	public void AfterThrowingAdvice(IllegalArgumentException ex) {
		 System.out.println("There has been an exception: " + ex.toString());
	}
	 
}
